package com.supergdtop.www.run.tools;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by chn10 on 2016/10/23.
 */

public class DbOpenhelper extends SQLiteOpenHelper {

    private static String DATABASENAME = "secn.db";
    private static int DATABASEVERSION = 2;
    /**
     * (Context context, String name, CursorFactory factory,int version)
     * @param context 上下文对象
     * @param name 数据库名称 secb.db
     * @param factory  游标工厂
     * @param version 数据库版本
     */
    public DbOpenhelper(Context context)
    {
        super(context, DATABASENAME, null, DATABASEVERSION);
    }

    public void onCreate(SQLiteDatabase db)
    {
        //执行有更新行为的sql语句
        db.execSQL("CREATE Table person (personid integer primary key autoincrement, name varchar(20), amount integer,age integer)");
    }

    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
    {
        db.execSQL("drop table if exists person");
        onCreate(db);
    }
}
